package com.sky.mapper;


import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {

    List<ShoppingCart> list(ShoppingCart shoppingCart);

    /**
     * 更新数据
     * @param cart
     */
    @Update("update shopping_cart set number=#{number} where dish_id=#{dishId}")
    void update(ShoppingCart cart);

    /**
     * 插入数据
     * @param shoppingCart
     */
    @Insert("insert into shopping_cart(name, image, user_id, dish_id, setmeal_id, dish_flavor, amount, create_time,number)" +
            " values(#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{amount},#{createTime},#{number}) ")
    void insert(ShoppingCart shoppingCart);

    /**
     * 查询用户id所有的购物车数据
     * @param currentId
     * @return
     */
    @Select("select * from shopping_cart where user_id=#{currentId}")
    List<ShoppingCart> select(Long currentId);

    /**
     * 清空购物车
     * @param currendId
     */
    @Delete("delete from shopping_cart where user_id=#{currendId}")
    void delete(Long currendId);

    @Delete("delete from shopping_cart where id=#{id}")
//    void deleteById(ShoppingCartDTO shoppingCartDto, Long currendId);
    void deleteById(Long id);
    @Update("update shopping_cart set number=#{number} where id=#{id}")
    void updateNumberById(ShoppingCart shoppingCart);
}
